<template>
  <div id="app">
    <nav class="navbar">
      <div class="nav-links">
        <router-link to="/" class="nav-link">预约</router-link>
        <router-link to="/User" class="nav-link">用户</router-link>
        <router-link to="/Reservation" class="nav-link">订单</router-link>
       </div>
      <div class="nav-buttons">
        <button @click="toggleDialog('login')" class="nav-button" >登录</button>
        <button @click="toggleDialog('register')" class="nav-button" >注册</button>
      </div>
    </nav>
    <router-view></router-view>
    <Login v-model="loginDialogVisible"/>
    <Register v-model="registerDialogVisible"/>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex';
import Login from './components/Login.vue';
import Register from './components/Register.vue';

const store = useStore();

const loginDialogVisible = computed({
  get: () => store.state.auth.loginDialogVisible,
  set: value => store.commit('auth/TOGGLE_LOGIN_DIALOG', value),
});

const registerDialogVisible = computed({
  get: () => store.state.auth.registerDialogVisible,
  set: value => store.commit('auth/TOGGLE_REGISTER_DIALOG', value),
});

const toggleDialog = (dialogType) => {
  if (dialogType === 'login') {
    loginDialogVisible.value = !loginDialogVisible.value;
  } else if (dialogType === 'register') {
    console.log("app",registerDialogVisible.value);
    registerDialogVisible.value = !registerDialogVisible.value;
    console.log("app",registerDialogVisible.value);
  }
};
</script>

<style>
#app {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  text-align: center;
  color: #333;
}

.navbar {
  display: flex;
  justify-content: space-between;
  background-color: #0078D7;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
  padding: 10px 40px;
  margin-top: -50px;
}

.nav-links {
  display: flex;
  justify-content: flex-start;
}

.nav-link {
  color: #fff; /* White color for links */
  text-decoration: none;
  padding: 5px 15px;
  transition: background-color 0.3s, box-shadow 0.3s;
  border-radius: 5px;
  margin: 0 15px;
  font-size: 20px;
}

.nav-link:hover {
  background-color:#00558C;
}

.nav-buttons {
  display: flex;
}

.nav-button {
  color: #333;
  background-color: #fff; /* White color for buttons */
  border: none;
  padding: 5px 15px;
  transition: background-color 0.3s, box-shadow 0.3s;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 10px;
}

.nav-button:hover {
  background-color: #f0f0f0; /* Light grey color on hover */
}
</style>
